<template>
	<view>
		<view>App授权</view>
		<button type="default" @click="userLogin('qq')">QQ授权登陆</button>
		<button type="default" @click="userLogin('weixin')">微信授权登陆</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			userLogin(type){
				uni.getProvider({
					service:"oauth",
					success(res) {
						//判断是否存在该供应商
						if(res.provider.indexOf(type)!==-1){
							uni.login({
								provider:type,
								success: (res) => {
									//获取用户信息
									uni.getUserInfo({
										provider:type,
										success: (info) => {
											console.log(info)
										}
									})
									console.log(res)
								},fail: (err) => {
									console.log(err)
								},complete: () => {
									
								}
							})
						}
						console.log(res)
					}
				})
			}
			
		}
	}
</script>

<style>

</style>
